//暴力破解



function  getLongest(arr){
  let maxLength = 0;
  let newArr = []


  function longest(index,seq){

    let current  = arr[index];
    // console.log(current)
    let newSeq = [...seq,current]

    for (let i = index+1 ;i<arr.length;i++){

      if(current < arr[i]){
        longest(i,newSeq)
      }

    }
    // console.log(newSeq)


    if (maxLength < newSeq.length) {
      newArr = newSeq
      maxLength = newSeq.length;
    }
    // console.log(newArr)

  }


  for (let i = 0; i < arr.length; i++) {
    longest(i,[])
  }

return newArr
}



const arr = [1,5,3,6,9,2,1]

// console.log(getLongest(arr))





